module main;

import hunt.framework;
import app.middleware.CheckTokenMiddleware;

void main(string[] args)
{
    // app().run(args);

    Application app = Application.instance();
    // 启动后
    app.onBooted(() {
        // admin路由组
        auto adminRouteGroup = app.route().group("admin");

        // admin路由组，使用CheckTokenMiddleware中间件进行token检查
        adminRouteGroup.withMiddleware(CheckTokenMiddleware.stringof);

        // admin路由组中不进行检查的路由
        // 1. 登录
        adminRouteGroup.get("login.login").withoutMiddleware(CheckTokenMiddleware.stringof);
        // 2. 分类列表
        adminRouteGroup.get("category.list").withoutMiddleware(CheckTokenMiddleware.stringof);
        // 3. 分类详情
        adminRouteGroup.get("category.detail").withoutMiddleware(CheckTokenMiddleware.stringof);
        // 4. 文章列表
        adminRouteGroup.get("article.list").withoutMiddleware(CheckTokenMiddleware.stringof);
        // 5. 文章详情
        adminRouteGroup.get("article.detail").withoutMiddleware(CheckTokenMiddleware.stringof);
        // 6. 某分类下全部文章
        adminRouteGroup.get("article.cateArtList").withoutMiddleware(CheckTokenMiddleware.stringof);
    });

    app.run(args);
}
